package com;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

/**
 * @ClassName MyBeanPostProcessor
 * @Description BeanPostProcessor是Spring IOC容器给我们提供的一个扩展接口。
 * @Author hanjiale
 * @Date 2021/11/13 10:13
 * @Version 1.0
 */
public class MyBeanPostProcessor implements BeanPostProcessor {

    public MyBeanPostProcessor() {
        super();
        System.out.println("这是BeanPostProcessor实现类构造器！！");
        // TODO Auto-generated constructor stub
    }

    /**
     * spring ioc 实例化对象后调用
     * @param arg0 要处理的bean对象
     * @param arg1 要处理的beanName
     * @return 要处理的bean对象
     * @throws BeansException
     */
    @Override
    public Object postProcessAfterInitialization(Object arg0, String arg1)
            throws BeansException {
        System.out.println("BeanPostProcessor接口方法postProcessAfterInitialization对属性进行更改！");
        return arg0;
    }

    /**
     * spring ioc 实例化对象前调用
     * @param arg0 要处理的bean对象
     * @param arg1 要处理的beanName
     * @return 要处理的bean对象
     * @throws BeansException
     */
    @Override
    public Object postProcessBeforeInitialization(Object arg0, String arg1)
            throws BeansException {
        System.out.println("BeanPostProcessor接口方法postProcessBeforeInitialization对属性进行更改！");
        return arg0;
    }
}
